package com.sky.mapper;

import com.sky.entity.SetmealDish;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetmealDishMapper {

    /**
     * 根据菜品id查询对应的套餐id
     * @param dishIds
     * @return
     */
    List<Long> getSetmeaByDishIds(List<Long> dishIds);

    /**
     * 根据套餐id查询套餐和菜品的关联关系
     * @param setmealId
     * @return
     */
    @Select("select * from setmeal_dish where id = #{setmealId}")
    List<SetmealDish> getbySetmealId(Long setmealId);

    /**
     * 根据setmeal的id删除套餐和菜品的关联关系
     * @param setmealId
     */
    @Delete("delete from setmeal_dish where id = #{id}")
    void deleteBySetmealId(Long setmealId);


    /**
     * 根据id插入套餐和菜品的关联关系
     * @param setmealDishes
     */
    void insertBatch(List<SetmealDish> setmealDishes);

    /**
     * 根据菜品id集合找出所有的套餐id，放到集合
     * @param dishIds
     * @return
     */
    @Select("select setmeal_id from setmeal_dish where dish_id in (#{dishIds})")
    List<Long> getSetmealIdByDishIds(List<Object> dishIds);
}
